/**
 * Sample React Native App
 * https://github.com/facebook/react-native
 */
'use strict';
import * as types from '../actions/actionTypes';

const initialState = {
    isNewRefreshing:false,
    isHotRefreshing:false,
    isDetailRefreshing:false,
    newsLastestSource:[],
    newsHotSource:[],
    newsDetailSource:{}
};

export default function news(state=initialState, action={}) {
  switch (action.type) {
    case types.REQUEST_NEWS_LIST:
        return Object.assign({}, state, {
            isNewRefreshing:true,
        });
    case types.REQUEST_NEWS_LIST_HOT:
        return Object.assign({}, state, {
            isHotRefreshing:true,
        });
    case types.REQUEST_NEWS_DETAIL:
        return Object.assign({}, state, {
            isDetailRefreshing:true,
        });
    case types.RECEIVE_NEWS_LIST:
        return Object.assign({}, state, {
            isNewRefreshing:false,
            newsLastestSource:action.data,
        });
    case types.RECEIVE_NEWS_LIST_HOT:
        return Object.assign({}, state, {
            isHotRefreshing:false,
            newsHotSource:action.data,
        });
    case types.RECEIVE_NEWS_DETAIL:
        return Object.assign({}, state, {
            isDetailRefreshing:false,
            newsDetailSource:action.data,
        });                                    
    default:
      return state;
  }
}